package com.hskn.hss.module.totalcost.to;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.hskn.hss.core.domain.BaseEntity;
import com.hskn.hss.utils.Tools;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * @author zcy
 */
@Data
@ApiModel(value = "车辆费用汇总-TO", description = "车辆费用汇总-TO")
public class SummaryVehicleCostTO extends BaseEntity implements Serializable {
    @ApiModelProperty(value = "机构类型", name = "depTypeName", example = "")
    private String depTypeName;
    @ApiModelProperty(value = "机构id", name = "depId", example = "")
    private String depId;
    @ApiModelProperty(value = "费用类型", name = "costType", example = "")
    private String costType;
    @ApiModelProperty(value = "车辆类型", name = "carType", example = "")
    private String carType;
    @ApiModelProperty(value = "车牌号", name = "carName", example = "")
    private String carName;
    @ApiModelProperty(value = "开始时间", name = "startTime", example = "2021-09-22")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startDate;
    @ApiModelProperty(value = "结束时间", name = "endTime", example = "2021-09-22")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endDate;
    @ApiModelProperty(value = "页数", name = "page", example = "1")
    private Integer page;
    @ApiModelProperty(value = "页面大小", name = "size", example = "10")
    private Integer size;


    public Date getStartDate() {
        if (null != startDate) {
            return Tools.getFristDayForDate(startDate);
        }
        return Tools.getFirstDayOfYear(new Date());
    }

    public Date getEndDate() {
        if (null != endDate) {
            return Tools.getLastDayForDate(endDate);
        }
        return Tools.getLastDayForDate(new Date());
    }
    public Integer getPage() {
        if(Objects.isNull(page)){
            return 1;
        }
        return page;
    }

    public Integer getSize() {
        if(Objects.isNull(size)){
            return 10;
        }
        return size;
    }
}
